public class PaintFill {
  public void paintIt(Color[][] screen, int x, int y, Color ncolor, Color ocolor) {
    if(x < 0 || y < 0||x >= screen[0].length||y >= screen.length)
      return;
    
    if(screen[y][x] == ocolor)
      screen[y][x] = ncolor;
    paintIt(screen, x+1, y, ncolor, ocolor);
    paintIt(screen, x-1, y, ncolor, ocolor);
    paintIt(screen, x, y+1, ncolor, ocolor);
    paintIt(screen, x, y-1, ncolor, ocolor);

    return;
  }

  public void paintIt(Color[][] screen, int x, int y, Color ncolor) {
    Color ocolor = Color[y][x];
    paintIt(screen, x, y, ncolor, ocolor);
  }
}